def solve(str):
    list_stack = []
    for c in str:
        if c == "(":
            list_stack.append(")")
        elif c == "[":
            list_stack.append("]")
        elif c == "{":
            list_stack.append("}")
        else:
            if len(list_stack) == 0 or list_stack.pop() != c:
                return False

    return len(list_stack) == 0


if __name__ == "__main__":
    str = "()[]{}"
    print(solve(str))
